//用户前台service
export default {
    //查询
    get: () =>
        new Promise(resolve => {
            $.ajax({
                url: '/api/users',
                type: 'GET',
                success: data => resolve(data)
            });
        }),
    //新增
    create: ({ username, password } = {}) =>
        new Promise(resolve => {
            $.ajax({
                url: '/api/users/create',
                type: 'POST',
                data: { username, password },
                success: data => resolve(data)
            });
        }),
    //删除
    remove: (user) =>
        new Promise(resolve => {
            $.ajax({
                url: '/api/users/remove',
                type: 'POST',
                data: user,
                success: data => resolve(data)
            });
        }),
    //更新
    update: (user) =>
        new Promise(resolve => {
            $.ajax({
                url: '/api/users/update',
                type: 'POST',
                data: user,
                success: data => resolve(data)
            });
        }),
    //验证注册名
    isUse: (username) =>
        new Promise(resolve => {
            $.ajax({
                url: "/api/users/isUse",
                type: "POST",
                data: {username},
                success: data => resolve(data)
            });
        })
}